Processor register

In computer architecture, a processor register is a small amount of storage available as part of a CPU or other digital processor. Such registers are (typically) addressed by mechanisms other than main memory and can be accessed more quickly. Almost all computers, load-store architecture or not, load data from a larger memory into registers where it is used for arithmetic, manipulated, or tested, by some machine instruction. Manipulated data is then often stored back in main memory, either by the same instruction or a subsequent one. Modern processors use either static RAM or dynamic RAM as main memory, the latter often being implicitly accessed via one or more cache-levels. A common property of computer programs is locality of reference: the same values are often accessed repeatedly and frequently used values held in registers improves performance. This is what makes fast registers (and caches) meaningful.

Processor registers are normally at the top of the memory hierarchy, and provide the fastest way to access data. The term normally refers only to the group of registers that are directly encoded as part of an instruction, as defined by the instruction set. However, modern high performance CPUs often have duplicates of these "architectural registers" in order to improve performance via register renaming, allowing parallel and speculative execution. Modern x86 is perhaps the most well known example of this technique.[1]

Allocating frequently used variables to registers can be critical to a program's performance. This register allocation is either performed by a compiler, in the code generation phase, or manually, by an assembly language programmer.

Contents

Categories of registers

Registers are normally measured by the number of bits they can hold, for example, an "8-bit register" or a "32-bit register". A processor often contains several kinds of registers, that can be classified accordingly to their content or instructions that operate on them:

Hardware registers are similar, but occur outside CPUs.

Some examples

Architecture Integer
registers
FP
registers
x86 8 8
x86-64 16 16
IBM/360 16 4
Z/Architecture 16 16
Itanium 128 128
UltraSPARC 32 32
IBM POWER 32 32
Alpha 32 32
6502 3 0
PIC microcontroller 1 0
AVR microcontroller 32 0
ARM 4 4
ARM 64bit[2] 8 8

The table shows the number of registers of several mainstream architectures. Note that the stack pointer (ESP) is counted as an integer register on x86-compatible processors, even though there are a limited number of instructions that may be used to operate on its contents. Similar caveats apply to most architectures. x86 FPUs have 8 80-bit stack levels in legacy mode, and at least 8 128-bit XMM registers in SSE modes.

Although all of the shown architectures are different, 95% of the computer architectures are based on a basic architecture known as Von Neumann architecture proposed by Von Neumann.

Register usage

The number of registers available on a processor and the operations that can be performed using those registers has a significant impact on the efficiency of code generated by optimizing compilers. The Strahler number defines the minimum number of registers required to evaluate an expression tree.

See also

Notes and references

  1. ^ Since around 1995 and the Pentium Pro, Cyrix 6x86, Nx586, and AMD K5.
  2. ^